# 1、定义项目名+jar名 & echo输出  2、进入当前部署目录 3、停止容器 4、删除容器 5、删除镜像 6、创建新的镜像
export PROJECT_NAME=xj-doc-server
export JAR_NAME=xj-doc-server
echo $PROJECT_NAME && echo $JAR_NAME
cd /workspace/$PROJECT_NAME
docker stop $PROJECT_NAME
docker rm $PROJECT_NAME
docker rmi $PROJECT_NAME:v1
docker build --build-arg JAR_NAME=$JAR_NAME -t $PROJECT_NAME:v1 .


## 启动容器 (需挂载文件 File+upload)
docker run --name $PROJECT_NAME -p 9066:9066 \
-e JAVA_OPTS='-Xms256m -Xmx512m -Dspring.profiles.active=pro' \
-e JAR_NAME=$JAR_NAME \
-e TZ=Asia/Shanghai \
-v /etc/localtime:/etc/localtime \
-v /workspace/$PROJECT_NAME/File:/File \
-v /workspace/$PROJECT_NAME/sitemap:/sitemap \
-v /workspace/$PROJECT_NAME/dist:/dist \
-v /workspace/$PROJECT_NAME/upload:/upload \
-v /workspace/$PROJECT_NAME:/data \
-d -it $PROJECT_NAME:v1 /bin/bash

docker logs -f $PROJECT_NAME
